Method and apparatus for reducing pool starvation in a shared memory switch

ABSTRACT

A switch includes a reserved pool of buffers in a shared memory. The reserved pool of buffers is reserved for exclusive use by an egress port. The switch includes pool select logic which selects a free buffer from the reserved pool for storing data received from an ingress port to be forwarded to the egress port. The shared memory also includes a shared pool of buffers. The shared pool of buffers is shared by a plurality of egress ports. The pool select logic selects a free buffer in the shared pool upon detecting no free buffer in the reserved pool. The shared memory may also include a multicast pool of buffers. The multicast pool of buffers is shared by a plurality of egress ports. The pool select logic selects a free buffer in the multicast pool upon detecting an IP Multicast data packet received from an ingress port.

CROSS-REFERENCES TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.14/097,614, filed on Dec. 5, 2013. U.S. patent application Ser. No.14/097,614 is a continuation of U.S. patent application Ser. No.13/204,145, filed on Aug. 5, 2011 which is now U.S. Pat. No. 8,630,304.U.S. patent application Ser. No. 13/204,145 is a continuation of U.S.patent application Ser. No. 12/775,696, filed on May 7, 2010 which isnow U.S. Pat. No. 7,996,485. U.S. patent application Ser. No. 12/775,696is a continuation of U.S. patent application Ser. No. 12/139,007, filedon Jun. 13, 2008 which is now U.S. Pat. No. 7,743,108. U.S. patentapplication Ser. No. 12/139,007 is a divisional of U.S. patentapplication Ser. No. 11/323,814, filed on Dec. 29, 2005 which is nowU.S. Pat. No. 7,403,976. U.S. patent application Ser. No. 11/323,814 isa continuation of U.S. patent application Ser. No. 09/624,276, filed onJul. 24, 2000 which is now U.S. Pat. No. 7,007,071. U.S. patentapplication Ser. No. 14/097,613, U.S. Pat. No. 8,630,304, U.S. Pat. No.7,996,485, U.S. Pat. No. 7,743,108, U.S. Pat. No. 7,403,976, and U.S.Pat. No. 7,007,071 are incorporated herein by reference in theirentireties.

BACKGROUND OF THE INVENTION

A networking switch receives data packets at ingress ports and forwardsthe data packets to one or more egress ports. The switch determines theegress port or ports to which the data packets are forwarded dependenton a destination address included in the data packet. A data packetreceived from an ingress port is stored in memory in the switch beforebeing forwarded.

The memory in the switch may be a shared memory in which all receiveddata packets are stored before being forwarded. As the received data isstored in the shared memory, a data packet pointer; that is, a pointerto the location of the received data in shared memory is stored in oneor more queues. The data packet pointer may be queued dependent on theingress port at which it was received or the egress port at which it isto be transmitted. An output buffered switch queues a data packetpointer dependent on the egress port at which it is to be transmitted.

The shared memory is shared by all the egress ports and a location israndomly allocated to an egress port for storing a received data packetto be forwarded to the egress port. The number of data packetstransmitted through each egress port can vary dramatically resulting intemporary congestion in a particular egress port. Temporary congestionmay occur at an egress port if data packets received from a plurality ofingress ports are to be forwarded through the same egress port or ifthere is a speed mismatch between the ingress port and the egress port,for example, the ingress port receives data, at 1 Gigabits per secondand the egress port transmits data at 100 Megabits per second.

SUMMARY OF THE INVENTION

A shared memory provides more memory for use by a congested egress portbut all the shared memory may be consumed storing data for a congestedegress port leaving no memory available for storing data to be forwardedto non-congested egress ports. This results in data packets beingdropped for non-congested egress ports.

In accordance with the invention, a shared memory switch including areserved pool of buffers in the shared memory is presented. The reservedpool of buffers is reserved for an egress port. The switch includes poolselect logic which selects a free buffer from the reserved pool forstoring data received from an ingress port to be forwarded to the egressport.

The shared memory also includes a shared pool of buffers. The sharedpool of buffers is shared by a plurality of egress ports. Upon detectingno free buffer in the reserved pool, the pool select logic selects afree buffer in the shared pool.

The shared memory may also include a multicast pool of buffers. Themulticast pool of buffers is shared by a plurality of egress ports. Thepool select logic selects a free buffer in the multicast pool upondetecting an IP Multicast data packet received from an ingress port.

BRIEF DESCRIPTION OF THE DRAWINGS

The foregoing and other objects, features and advantages of theinvention will be apparent from the following more particulardescription of preferred embodiments of the invention, as illustrated inthe accompanying drawings in which like reference characters refer tothe same parts throughout the different views. The drawings are notnecessarily to scale, emphasis instead being placed upon illustratingthe principles of the invention.

FIG. 1 is a block diagram of a shared memory switch;

FIG. 2 is a block diagram of the shared memory shown in FIG. 1illustrating the reserved pools, shared pool and multicast pool;

FIG. 3 is a block diagram of the pool select logic in the packet storagemanager shown in FIG. 1;

FIG. 4 is a block diagram of the pool counters shown in FIG. 3;

FIG. 5 is a flowchart illustrating the steps for selecting a poolimplemented in pool counter logic shown in FIG. 3; and

FIG. 6 is a flowchart illustrating the steps for returning a buffer to apool implemented in pool counter logic shown in FIG. 3.

DETAILED DESCRIPTION OF THE INVENTION

A description of preferred embodiments of the invention follows.

FIG. 1 is a block diagram of a shared memory switch 100. All datareceived on ingress ports 102 is stored in shared memory 108 beforebeing forwarded to one or more egress ports 112 _(0-n). The packetstorage manager 106 controls write and read access to the shared memory108. The packet storage manager 106 includes pool select logic 124. Thepool select logic 124 logically portions the shared memory 108 into ashared pool, a multicast pool and a plurality of reserved pools asillustrated in FIG. 2. There is no actual physical portioning of theshared memory 108.

The pool select logic 124 manages the buffers in each pool by selectinga pool from which to allocate a buffer. A buffer is allocated from theegress port's reserved pool if the number of allocated buffers for anegress port 112 is less than a reserved threshold count. The pool selectlogic 124 is described later in conjunction with FIG. 2. Read and writeaccess to the shared memory 108 is described in co-pending U.S. patentapplication Ser. No. 09/386,589 filed on Aug. 31, 1999 entitled “Methodand Apparatus for an Interleaved Non-Blocking Packet Buffer” by David A.Brown which is incorporated herein by reference in its entirety.

The switch 100 includes an ingress ports engine 104 and an egress portsengine 110. A data packet is received serially at an ingress port 102.The ingress engine 104 detects and processes headers in the receiveddata packet, determines from the detected header on which egress port112 _(0-n) to forward the data packet and generates a forward vector 114for the data packet. The forward vector 114 is a bit map, with a bitcorresponding to each of the plurality of egress ports 112 _(0-n),indicating whether the data packet is to be forwarded to that egressport 112 _(0-n). A method and apparatus for generating a forward vector114 is described in co-pending U.S. patent application Ser. No.09/453,344 filed Dec. 1, 1999 entitled “Method and Apparatus forWire-Speed IP Multicast Forwarding” by David A. Brown (now U.S. Pat. No.6,754,211), the entire teachings of which are incorporated herein byreference in its entirety. The forward vector 114 is forwarded to thepacket storage manager 106.

The packet storage manager 106 provides shared memory addresses 122 forread and write operations to the shared memory 108 and stores thelocations in the shared memory 108 of each data packet stored in one ormore egress port queues (not shown). A method and apparatus forproviding egress port queues is described in co-pending U.S. patentapplication Ser. No. 09/559,190 filed on Apr. 27, 2000 entitled “PortPacket Queuing” by Richard M. Wyatt (now U.S. Pat. No. 7,236,489),incorporated herein by reference in its entirety. The egress engine 110through select 120 selects one of the plurality of egress ports 112_(0-n), on which to transmit a data packet and provides the stored datapacket to the selected egress port 112 _(0-n).

The shared memory 108 stores data packets received from any of theingress ports 102 for transmitting to any of the egress ports 112_(0-n). The switch 100 provides concurrent processing by the ingressport engine 104 of data packets received at ingress ports 102 andprocessing of stored data packets by the egress port engine 110 forforwarding on egress ports 112 _(0-n).

As a data packet is received serially on one of the ingress ports 102,the serial data may be grouped into data segments. Each data segment isstored in a buffer in shared memory 108. Thus, the size of a buffer isdependent on the size of a data segment. The size of a data segment isdependent on the networking protocol supported by the switch 100. Forexample, for the Ethernet networking protocol, the size selected for thedata segment is 64 bytes because the minimum data packet size for anEthernet data packet is 64 bytes.

The ingress ports engine 104 also determines from the header included ina received data packet if a data packet is an IP Multicast data packet.The switch 100 forwards a copy of an IP Multicast data packet to eachmember of the IP Multicast group. A single copy of the data packet isstored in shared memory 108 with a Multicast Forwarding Index (“MFI”) asis described in co-pending U.S. patent application Ser. No. 09/453,344filed Dec. 1, 1999 entitled “Method and Apparatus for Wire-Speed IPMulticast Forwarding” by David A. Brown (now U.S. Pat. No. 6,754,211),which is incorporated herein by reference in its entirety. Members ofthe IP Multicast group may be connected to the same egress port 112 orto more than one egress port 112. Multiple copies of the IP Multicastdata packet are forwarded to an egress port 112, one for each member ofthe IP Multicast group connected to the egress port 112. If the receiveddata packet is an IP Multicast data packet, the ingress ports engine 104forwards a multicast tag 126 with the forward vector 114 indicating thatthe received data packet is an IP Multicast data packet. The multicasttag 126 indicates whether the received data packet is an IP Multicastdata packet. The multicast tag 126 can be implemented as a single bitset to ‘1’ if the received data packet is an IP Multicast data packet.

FIG. 2 is a block diagram of the shared memory 108 shown in FIG. 1logically portioned into a shared pool 200, a Multicast pool 204 and aplurality of reserved pools 202 ₀-202 _(n). A reserved pool 202 ₀-202_(n) is provided for each egress port 112 _(0-n). A reserved thresholdcount of buffers is assigned to each reserved pool 202 ₀-202 _(n). Thereserved threshold count of buffers may only be allocated for storingdata packets for the respective egress port 112. The shared pool 200 isprovided for storing data packets to be forwarded to any of the egressports 112 _(0-n). The Multicast pool 204 is provided for storing IPMulticast data packets to be forwarded to any of the egress ports 112_(0-n).

A buffer is allocated from the egress ports reserved pool 202 _(0-n)while the count of allocated buffers is below the threshold count. Ifthe number of reserved allocatable buffers has been exceeded, buffersare allocated from the shared pool 200. A buffer for a data packet canonly be allocated from the respective reserved pool 202 ₀-202 _(n)associated with the egress port 112 _(0-n). Thus, even if all thebuffers in the shared pool 200 are allocated to one congested egressport 112 _(0-n), a buffer is available for allocation to a non-congestedport from the non-congested port's respective reserve pool 202 ₀-202_(n).

If the data packet is an IP Multicast data packet, the data packet isstored once in shared memory 108 and a copy of the stored data packet isforwarded to members of the IP Multicast group. The IP Multicast datapacket is stored in shared memory 108 until the IP Multicast data packethas been forwarded to each member of the IP Multicast group.

As the stored IP Multicast data packet may be forwarded to more than oneegress port 112, it is difficult to select a port reserved pool 202 fromwhich to allocate a buffer in which to store the IP Multicast datapacket. Also, without keeping separate accounting for IP Multicast datapackets, it cannot be determined when an IP Multicast data packet isbeing dequeued whether it is from a reserved pool 202 or a shared pool200 because the buffer may not have been allocated from the reservedpool for the egress port to which the last IP Multicast data packet isforwarded. Having a separate pool for storing IP Multicast data packetsallows a switch 100 to limit the number of buffer resources that can beconsumed for storing IP Multicast data packets. Thus, a Multicast pool204 is provided to store IP Multicast data packets.

FIG. 3 is a block diagram of the pool select logic 124 in the packetstorage manager 106 shown in FIG. 1. The pool select logic 124 includespool counters 300 and pool counter logic 302. The pool counters 300include a counter for each pool 200, 202 ₀-202 _(n), 204 in sharedmemory 108. The counter status 304 is forwarded to the pool counterlogic 302.

The pool counter logic 302 selects the pool 200, 202 ₀-202 _(n) or 204from which to allocate a buffer dependent on the state of counter status304, the forward vector 114 and the Multicast tag 126 for the receiveddata packet to be stored in shared memory 108. After selecting the pool200, 202 ₀-202 _(n) or 204, the pool counter logic 302 generates counterincrement-decrement 306 to increment or decrement the respective counterin pool counters 300. The pool counter logic 302 also generates bufferavailable 308. The state of buffer available 308 indicates whether abuffer is available for storing a received non-Multicast data packet inshared memory 108. If no buffer is available for a non-Multicast datapacket in the shared pool 200 or the port reserved pool 202, or for aMulticast data packet in the Multicast pool 204, the received datapacket is dropped.

If a buffer is available in which to store the received data to beforwarded to an egress port, a buffer is allocated from a free list ofbuffers in shared memory 108 as described in conjunction with co-pendingU.S. patent application Ser. No. 09/386,589 filed on Aug. 31, 1999entitled “Method and Apparatus for an Interleaved Non-Blocking PacketBuffer” by David A. Brown (now U.S. Pat. No. 7,007,071), which isincorporated herein by reference in its entirety.

FIG. 4 is a block diagram of the pool counters 300 shown in FIG. 3. Thepool counters 300 include a shared free counter 400, a total freecounter 402, a Multicast free counter 416, a reserved free counter 428,a queue reserved threshold register 412, and a port reserve pool counter414 _(0-n) for each egress port 112 _(0-n) in the switch 100.

The total free counter 402 stores the total number of free buffers inshared memory 108. The total free counter 402 is preset with the sum ofthe buffers in the shared pool 200, the port reserve pools 202 ₀-202_(n), and the Multicast pool 204. The total free counter 402 isdecremented each time a buffer is allocated from any pool to store adata packet. If the pools are assigned as follows: reserved=500;shared=2000; Multicast=500, the sum of the buffers is 3000 equal to thetotal number of available buffers. IP Multicast data packets are droppedonce the 500 data packets in the Multicast pool 204 are used even ifthere are buffers available in the shared pool 200.

There is a certain amount of “tuning” required in a switch. The tuningincludes determining how to divide the shared memory 108 to reduce theprobability of dropping data packets during congestion. Most congestionoccurs when there are bursts of data colliding together at an outputport. Depending on factors such as burst length and others, the dropprobability varies dependent on the over subscription ratios of thepools in shared memory 108. Thus, the thresholds for the pools in sharedmemory 108 are modifiable dependent on expected load conditions.

In an alternative embodiment, the pools 200, 202 ₀-202 _(n) and 204 areoversubscribed. The total free counter 402 is initialized with the totalnumber of physical buffers in shared memory 108, The sum of the buffersin the shared pool 200, the port reserve pools 202 ₀-200 _(n) and theMulticast pool 204 is greater than the count stored in the total freecounter 402. This allows for better utilization of buffers in sharedmemory 108, but reduces the guarantee that there will be a bufferavailable in the port reserve pool 202.

For example, if the pools are assigned as follows: reserved pool=1000;shared pool=2000; Multicast pool=1000, the sum of the buffers is 4000but the total number of available buffers in shared memory 108 is 3000;that is, less than the sum of the buffers in the pools. This allowsbetter utilization of the buffers in shared memory 108 if there is moreMulticast data traffic than unicast and broadcast data traffic throughthe switch 100 because one third of the total number of availablebuffers may be allocated for storing IP Multicast data packets.

If the Multicast pool 204 is not oversubscribed, Multicast data packetsare dropped when the Multicast pool 204 is full even if there arebuffers available in shared memory 108. Thus, with over subscription, itis less likely that data packets are dropped when there are buffersavailable in shared memory 108. The disadvantage is that a buffer maynot be available in the reserved pool for a non-congested port even ifthe respective port reserved pool 202 is below its reserved threshold.

The shared free counter 400 stores the number of available or freebuffers in the shared pool 200. Buffers in the shared pool 200 of sharedmemory 108 may store a data packet for any egress port 112 _(0-n). Theshared free counter 400 is decremented each time a buffer is allocatedfrom the shared pool 200. Shared pool count 430 indicates whether thereare free buffers in the shared pool 200. The shared pool count 430 isforwarded to pool counter logic 302.

The Multicast free counter 416 stores the number of available buffers inthe Multicast pool 204. The port reserve pool counters 414 ₀, store thenumber of buffers allocated to the respective egress port 112 from therespective port reserve pool 202 ₀-202 _(n) and the shared pool 200. Aqueue reserved threshold register 412 stores the number of buffersreserved for allocation to a port reserve pool 202 ₀-202 _(n). One queuereserved threshold register 412 is provided lithe same number of buffersis reserved for allocation to each port reserve pool 202 ₀-202 _(n). Inan alternative embodiment each port reserve pool 202 ₀-202 _(n) may havea different number of buffers reserved for allocation and thus a queuereserved threshold register 412 is required for each port reserve poolcounter 414 _(0-n).

The reserved free counter 428 is preset to the sum of the buffersreserved for each egress port 112 or is preset to a number less than thesum. If the reserved free counter is preset to a number less than thesum, more reserved memory is provided per egress port but an egress portmay not be able to allocate all of the buffers in its respectivereserved pool. For example, if there are four reserve port pools eachwith 100 buffers reserved and the total reserved is set to 400. Uponreceiving a data packet to forward to an egress port, the packet isdropped if there are no free buffers in the shared pool and the egressport has no free buffers in its respective reserve port pool even ifthere are free buffers in the reserved pool. If each reserve port poolis oversubscribed to 150, each egress port may use up to 150 buffers ofthe 400 buffers in the reserved pool. Thus, more buffers are availablefor a congested port. However, by oversubscribing, an egress port is notguaranteed allocation of its reserved pool of buffers. For example, in aswitch with 4 ports and each reserve port pool oversubscribed to 150,with one congested port using 150 buffers, there are 250 buffersavailable for allocation to the other 3 ports.

Each of the counters 400, 402, 414 _(0-n), 416, and 428 has a respectivecounter increment-decrement signals 422, 404, 426 _(0-n), 410 and 436generated by the pool counter logic 302 and forwarded on counterincrement-decrement 306 (FIG. 3). A counter 400, 402, 414 _(0-n), 416,and 428 is incremented or decremented each time a buffer is allocated orfreed from a respective pool. For example, the shared free counter 400is decremented each time a buffer is allocated from the shared pool 200and incremented each time a buffer is freed back to the shared pool 200.The total free counter 402 is decremented each time a buffer isallocated from any pool and incremented each time a buffer is freed toany pool.

FIG. 5 is a flowchart illustrating the steps for selecting a pool 200,202 ₀-202 _(n), 204 in shared memory 108 from which to allocate a bufferimplemented in pool counter logic 302 shown in FIG. 3. FIG. 5 isdescribed in conjunction with FIG. 3 and FIG. 4.

At step 500, the pool counter logic 302 waits for notification of areceived data packet to be stored in shared memory 108. The notificationof a received data packet includes a forward vector 114 and a multicasttag 126 forwarded from the ingress ports engine 104. The forward vector114 indicates the egress ports 112 _(0-n) to which the received datapacket is to be forwarded. The Multicast tag 126 indicates whether thedata packet is an IP Multicast data packet. If a data packet isreceived, processing continues with step 502. If not, processingcontinues with step 500.

At step 502, the pool counter logic 302 determines if there is a bufferavailable in the shared memory 108 for storing the received data packet.A buffer is available in shared memory 108 if total free 408 is greaterthan zero. Total free 408 is the count of free buffers stored in thetotal free counter 402 (FIG. 4). If a buffer is available, processingcontinues with step 504. If not, processing continues with step 518.

At step 504, the pool counter logic 302 determines if the received datapacket is an IP Multicast data packet. The state of the Multicast tag126 indicates whether the data packet is an IP Multicast data packet. Ifthe data packet is an IP Multicast data packet, the data packet isstored once in shared memory 108 and a copy of the stored data packet isforwarded to each member of the IP Multicast group. The data packet maybe forwarded multiple times to one or more egress ports 112 _(0-n). Ifthe received data packet is an IP Multicast data packet, processingcontinues with step 520. If not, processing continues with step 505.

At step 505, the received data packet is a non-IP Multicast data packet.Thus, a buffer must be allocated from the shared pool 200 or the portreserve pool 202 ₀-202 _(n). The pool counter logic 302 determines ifthere is a buffer available in any of the port reserve pools 202 ₀-202_(n). A buffer is available if the reserved pool count 432 is greaterthan zero. The reserved pool count 432 is checked because the reservedpool 202 may be oversubscribed. Thus, even if the queue count 434 _(0-n)associated with the egress port 112 _(0-n) to which the received datapacket is to be forwarded is less than the reserved threshold 418, theremay not be a buffer available in the reserved pools 202. If there is abuffer available, processing continues with step 506. If not, processingcontinues with step 508.

At step 506, The pool counter logic 302 determines if there is a bufferavailable in the respective port reserve pool 202 ₀-202 _(n). A bufferis available if the queue count 434 _(0-n) associated with the egressport 112 _(0-n) to which the received data packet is to be forwarded isless than the reserved threshold 418. If so, processing continues withstep 512. If not, processing continues with step 508.

At step 508, no buffers are available in the respective port reservepool 202 ₀-202 _(n) of the shared memory 108. The pool counter logic 302determines if there is a buffer available in the shared pool 200. Abuffer is available if the shared pool count 430 is greater than zero.If so, processing continues with step 510. If not, processing continueswith step 518.

At step 510, a buffer is allocated from the shared pool 200. The poolcounter logic 302 updates the number of buffers available in the sharedpool 200 by decrementing the shared free counter 400 throughincrement-decrement shared 422. Processing continues with step 514.

At step 512, the pool counter logic 302 updates the number of buffersavailable in the port reserve pool 202 by decrementing the reserved freecounter 428 through increment-decrement reserved 436. Processingcontinues with step 514.

At step 514, the pool counter logic 302 updates the number of buffersused by the egress port by incrementing the port reserve pool counter414 through increment-decrement queue 426. The respective port reservepool counter 414 is selected dependent on the egress port 112 selectedin the forward vector 114. A buffer for a respective egress port may beallocated from the shared pool 200 or the respective port reserve pool202. Thus, the respective reserved queue count 434 may be greater thanthe reserved threshold 418. Processing continues with step 516.

At step 516, the pool counter logic 302 updates the total number of freebuffers in shared memory 108 by decrementing the total free counter 402through increment-decrement total 404. Processing continues with step526.

At step 518, there is no buffer available in shared memory 108. Theegress port 112 has used all the buffers from the respective portreserve pool 202 and all buffers in 20 the shared pool 200 are in use.The received data packet is dropped. Processing is complete.

At step 520, the received data packet is an IP Multicast data packet.Thus, a buffer must be allocated from the Multicast pool 204. The poolcounter logic 302 determines if there is a buffer available in theMulticast pool 204. A buffer is available if the multicast pool count420 is greater than zero. If so, processing continues with step 522. Ifnot, processing continues with step 518.

At step 522, the pool counter logic 302 updates the number of buffersavailable in the multicast pool 204 by decrementing the multicast freecounter 416 through increment-decrement multicast 410. Processingcontinues with step 524.

At step 524, the pool counter logic 302 sets multicast tag 310 toindicate that the buffer is to be allocated for an IP Multicast datapacket. The multicast tag 310 is stored with the pointer to theallocated buffer in shared memory 108 stored in an egress port queue(not shown) associated with each egress port 112 to which the IPMulticast data packet is to be forwarded. Processing continues with step526.

At step 526, a buffer is available for allocation. The pool counterlogic 302 indicates that a buffer is available for storing the receiveddata packet through buffer available 308. Processing is complete.

FIG. 6 is a flowchart illustrating the steps for returning a buffer to apool implemented in the pool counter logic 302 shown in FIG. 3.

At step 600, the pool counter logic 302 waits for notification of abuffer to be returned to shared memory 108 from the egress ports engine110. The egress ports engine 110 schedules the forwarding of a storeddata packet to an egress port 112 through select 120 forwarded to thepacket storage manager 106. The egress ports engine 110 includes anegress port queue (not shown) for each egress port 112. The egress portqueue stores pointers to allocated buffers in shared memory 108. Afterthe egress ports engine 110 has forwarded the data packet, the buffercan be freed. If the buffer is to be freed, processing continues withstep 602. If not, processing continues with step 602.

At step 602, the multicast tag 126 stored with the pointer of the bufferto be freed indicates whether the buffer was allocated from themulticast pool 204. If the buffer was allocated from the multicast pool,processing continues with step 605. If not, processing continues withstep 604.

At step 604, the pool counter logic 302 determines if the buffer is tobe returned to the shared pool 200 or to a port reserve pool 202. Thepool counter logic 302 examines the reserved queue count 434 associatedwith the egress port 112 to which the data packet was forwarded. If therespective reserved queue count 434 is greater than the reservedthreshold 418, the buffer is to be returned to the shared pool 200 andprocessing continues with step 610. If the respective reserved queuecount is less than the reserved threshold 418, the buffer is to bereturned to the respective port reserve pool 202 and processingcontinues with step 608.

At step 605, the pool counter logic 302 determines if a copy of the IPMulticast packet has been forwarded to all members of the IP Multicastgroup. The IP Multicast data packet received at the ingress port 102(FIG. 1) is stored in shared memory 108 (FIG. 1) until the IP Multicastdata packet has been forwarded to all members of the IP Multicast group.After the last IP Multicast data packet has been forwarded, the bufferin shared memory 106 storing the IP Multicast data packet can bereturned to the IP Multicast pool 204.

To determine if a copy of the IP Multicast data packet has beenforwarded to all members of the IP Multicast group, the number of portqueues (not shown) that the IP Multicast data packet has been queued onis stored in a port queue counter register (not shown). The counterregister is decremented each time a copy of the IP Multicast data packetis forwarded to the egress port 110 (FIG. 1). The number of port queuesis determined from the forward vector 114.

If a copy of the IP Multicast data packet has been forwarded to allmembers of the IP Multicast group, processing continues with step 606.If not, processing continues with step 600.

At step 606, the pool counter logic 302 updates the number of buffersavailable in the multicast pool 204 by incrementing the multicast freecounter 416 through increment-decrement multicast 410. Processingcontinues with step 614.

At step 608, the pool counter logic 302 updates the number of buffersused in the port reserve pools 202 by incrementing the reserved freecounter 428 through increment-decrement reserved 436. Processingcontinues with step 612.

At step 610, the pool counter logic 302 updates the number of buffersavailable in the shared pool 200 by incrementing the shared free counter400 through increment-decrement shared 422. Processing continues withstep 612.

At step 612, the pool counter logic 302 updates the number of buffersused by the egress port by decrementing the respective port reserve poolcounter 414 through increment-decrement queue 426. The respective portreserve pool counter 414 is selected dependent on the state of selectforwarded from the egress ports engine 110. Processing continues withstep 614.

At step 614, the pool counter logic 302 updates the total number ofbuffers available in shared memory 108 by incrementing the total freecounter 402 through increment-decrement total 404. Processing continueswith step 616.

At step 616, the buffer is freed by adding a pointer to the buffer to afree list. Processing is complete.

While this invention has been particularly shown and described withreferences to preferred embodiments thereof, it will be understood bythose skilled in the art that various changes in form and details may bemade therein without departing from the scope of the inventionencompassed by the appended claims.

1. (canceled)
 2. A switch comprising: a plurality of reserved pools ofbuffers in a shared memory, each reserved pool of buffers associatedwith one of a plurality of egress ports and reserved for storing data tobe forwarded to the egress port; a shared pool of buffers in the sharedmemory, the shared pool of buffers for storing data to be forwarded toany of the plurality of egress ports; a multicast pool of buffers in theshared memory reserved for storing Multicast packets received from anyingress port to be forwarded to at least one egress port to members of aMulticast group; and a pool select logic for selecting a free buffer toallocate from the multicast pool of buffers based on counts stored in:i) a counter of a total number of free buffers; and ii) a counter of anumber of buffers in the multicast pool of buffers, and wherein thecounter of the total number of free buffers is configured to be presetto a total number of buffers in the shared memory which is less than asum of: i) free buffers in the shared pool of buffers; ii) free buffersin the reserved pools of buffers; and iii) free buffers in the multicastpool of buffers.
 3. The switch as claimed in claim 2 wherein when nofree buffer is detected in a reserved pool that would otherwise beselected, the pool select logic selects a free buffer in the sharedpool.
 4. The switch as claimed in claim 2 wherein the pool select logicis configured to determine the availability of a free buffer in theshared memory dependent on the number of free buffers in the sharedmemory as stored in the counter of the total number of free buffers. 5.The switch as claimed in claim 2 wherein the Multicast packets are IPMulticast packets and the members of the Multicast group comprisemembers of an IP Multicast group.
 6. The switch as claimed in claim 2further comprising a plurality of ingress ports each configured toreceive data packets serially thereat.
 7. The switch as claimed in claim2 further comprising a port queue counter register configured to storethe number of port queues that the Multicast packet has been queued on.8. The switch as claimed in claim 7 wherein the port queue counterregister is evaluated to determine if a copy of the Multicast packet hasbeen forwarded to all members of the Multicast group.
 9. The switch asclaimed in claim 8 wherein the Multicast packets are IP Multicastpackets and the members of the Multicast group comprise members of an IPMulticast group.